You are here: Symbol Reference > Dew Namespace > Dew.Stats Namespace > Dew.Stats.Units Namespace > Classes > RegModels Class > RegModels Methods > RegModels.FracFit Method
Dew Stats for .NET
ContentsIndexHome
PreviousUpNext
RegModels.FracFit Method

Fits rational fraction equation to data.

Syntax
C#
Visual Basic
public static void FracFit([In] TVec B, [In] TVec X, [In] TVec Y, int DegNom, int DegDenom, bool Constant, [In] TVec Weights);
Parameters 
Description 
[In] TVec B 
Returns regression coefficients for rational function. 
[In] TVec X 
Vector of independent variable. 
[In] TVec Y 
Vector of dependent variable. 
int DegNom 
Nominator degree. 
int DegDenom 
Denominator degree. 
bool Constant 
If false, B[0] i.e. constant term in nominator is set to 0.0. 
[In] TVec Weights 
Weights (optional). Weights are used only if they are set. 

The routine fits equations to data by minimizing the sum of squared residuals. The observed values obey the following equation: 

 

where n and d are nominator and denominator polynomial degrees.

In the following example we generate some data. Then we fit power function to this data and retreive it's regression coefficients.

using Dew.Math; using Dew.Stats.Units; namespace Dew.Examples { private void Example(Steema.TeeChart.Styles.Line line1, Steema.TeeChart.Styles.Line line2) { Vector X = new Vector(100); Vector Y = new Vector(100); Vector B = new Vector(0); Vector YHat = new Vector(0); X.Ramp(-5.0, 0.05); // x= -5.0, -4.95, ... -0.05 Y.RandGauss(3.5, 0.12); // sample data // calculate coefficients RegModels.FracFit(B,X,Y,2,4,false,null); // evaluate y by using calculated coefficients RegModels.FracEval(B,X, YHat,2,false); MtxVecTee.DrawValues(X,Y,line1,false); MtxVecTee.DrawValues(X,YHat,line2,false); } }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!